#!/usr/bin/ruby

Commands.add_command(:freememory,Proc.new do
                       size=0
                       File.readlines("/proc/meminfo").each do |line|
                         @@log.info("read line:#{line}")
                         size=$1.to_f if line=~/^MemFree:\s+(\d+)\s+(\S+)/
                         size+=$1.to_f if line=~/^(?:Buffers|Cached):\s+(\d+)\s+(?:\S+)/
                         @@log.info "size:#{size}"
                       end
                       "%.2f %s"%[size/1024,'Mb']
                       end)
